<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${package_name}.mapper.${table_entity.entityName}Mapper">

    <resultMap id="baseResultMap" type="${package_name}.entity.${table_entity.entityName}">
        <id column="${table_entity.keyColumnProperty.columnName}" jdbcType="${table_entity.keyColumnProperty.columnType}" property="${table_entity.keyColumnProperty.propertyName}" />
        <#if property_columns?exists>
            <#list property_columns as model>
        <result column="${model.columnName}" jdbcType="${model.columnType}" property="${model.propertyName}" />
            </#list>
        </#if>
    </resultMap>

    <sql id="baseColumnSql">
        id
        <#if property_columns?exists>
            <#list property_columns as model>
        , ${model.columnName}
            </#list>
        </#if>
    </sql>

    <select id="findList" resultMap="baseResultMap">
        select
            <include refid="baseColumnSql" />
        from
            ${table_entity.tableName}
        where
            deleted = 0
        <#if property_columns?exists>
            <#list property_columns as model>
                <#if search_columns?exists>
                    <#if search_columns?seq_contains(model.columnName)>
                        <#if model.javaType == "String">
            <if test="condition.${model.propertyName} != null and condition.${model.propertyName} != ''">
                and INSTR(${model.columnName}, <#noparse>#{condition.</#noparse>${model.propertyName}<#noparse>}</#noparse>) > 0
            </if>
                        <#else >
            <if test="condition.${model.propertyName} != null and condition.${model.propertyName} != ''">
                and ${model.columnName} = <#noparse>#{condition.</#noparse>${model.propertyName}<#noparse>}</#noparse>
            </if>
                        </#if>
                    </#if>
                </#if>
            </#list>
        </#if>
        order  by create_time desc
    </select>

</mapper>